#!/bin/bash

# MAVEN_VERSION=3.6.3
# COMMAND_LINE_TOOLS_VERSION=8512546
# GRADLE_VERSION=6.7.1
HOST=http://update.gonsincloud.com/jenkins
CURRENT_PATH=${PWD}
cd ~
mkdir .jenkins_environment
cd .jenkins_environment
cp -rf ${CURRENT_PATH}/* ./
wget -nc ${HOST}/apache-maven-3.6.2-bin.tar.gz apache-maven-3.6.2-bin.tar.gz
# wget -nc https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz apache-maven-${MAVEN_VERSION}-bin.tar.gz
# axel -a -n 20 -o apache-maven-${MAVEN_VERSION}-bin.tar.gz https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
wget -nc ${HOST}/commandlinetools-linux-8512546_latest.zip commandlinetools-linux-8512546_latest.zip
# wget -nc https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip
# axel -a -n 20 -o commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip 
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip 
wget -nc ${HOST}/gradle-6.7.1-bin.zip gradle-6.7.1-bin.zip
# wget -nc https://services.gradle.org/distributions/gradle-6.7.1-bin.zip gradle-${GRADLE_VERSION}-bin.zip
# axel -a -n 20 -o gradle-${GRADLE_VERSION}-bin.zip https://services.gradle.org/distributions/gradle-6.7.1-bin.zip 
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://services.gradle.org/distributions/gradle-6.7.1-bin.zip 
wget -nc ${HOST}/jdk-8u231-linux-x64.tar.gz jdk-8u231-linux-x64.tar.gz
# axel -a -n 100 -o jdk-8u231-linux-x64.tar.gz https://download.oracle.com/otn/java/jdk/8u351-b10/10e8cce67c7843478f41411b7003171c/jdk-8u351-linux-x64.tar.gz
# wget -nc https://download.oracle.com/otn/java/jdk/8u351-b10/10e8cce67c7843478f41411b7003171c/jdk-8u351-linux-x64.tar.gz jdk-8u231-linux-x64.tar.gz 

wget -nc ${HOST}/node-v16.16.0-linux-x64.tar node-v16.16.0-linux-x64.tar
# axel -a -n 20 -o node-v16.16.0-linux-x64.tar.gz https://nodejs.org/dist/v16.16.0/node-v16.16.0-linux-x64.tar.gz 
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://nodejs.org/dist/v16.16.0/node-v16.16.0-linux-x64.tar.gz 

wget -nc ${HOST}/Python-3.10.5.tar.xz Python-3.10.5.tar.xz 
# axel -a -n 20 -o Python-3.10.5.tar.xz https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tar.xz 
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tar.xz

wget -nc ${HOST}/docker-compose  docker-compose
# curl -SL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64 -o docker-compose
# axel -a -n 20 -o docker-compose https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64
# sudo wget -nc ${HOST}/docker-compose
wget -nc ${HOST}/apache-jmeter-5.3.tgz apache-jmeter-5.3.tgz
# axel -a -n 20 -o apache-jmeter-5.5.tgz https://dlcdn.apache.org/jmeter/binaries/apache-jmeter-5.5.tgz 
# aria2c --file-allocation=none -c -x 10 -s 10 -d "${CURRENT_PATH}/.jenkins_environment" https://dlcdn.apache.org/jmeter/binaries/apache-jmeter-5.5.tgz 

chmod +x docker-compose
sudo chmod 777 docker-compose.yml
sudo docker-compose --version
sudo chmod 777 *
sudo docker-compose down
sudo docker-compose build
sudo docker-compose up -d
